package com.mlk.cash.api;

import com.mlk.cash.service.CashService;
import com.mlk.core.util.ServerResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 积分兑现
 */
@RequestMapping("/api/cash")
@RestController
public class CashAPI {

    @Resource
    private CashService cashService;

    /**
     * 获取积分比例
     * @return
     */
    @GetMapping("getCashRate")
    public ServerResponse getCashRate(String openId){
        return this.cashService.getCashRate(openId);
    }

    /**
     * 积分兑现
     * openId ,需要兑换的积分数
     * @return
     */
    @PostMapping("doCash")
    public ServerResponse doCash(String openId, Integer amount){
        return this.cashService.doCash(openId,amount);
    }

}
